const Koa = require('koa');
const app = new Koa();
const {koaSwagger} = require("koa2-swagger-ui");

const attractionRoute = require('./routes/attractionsRoute'); // 添加: 引入景点路由
const routesRoute = require('./routes/routesRoute');
const ticketsRoute = require('./routes/ticketsRoute');
const activityRoute = require('./routes/activitiesRoute');
const accommodationRoute = require('./routes/accommodationRoute');
const swaggerConfig = require('./config/swaggerConfig');

// 使用 Swagger 路由
app.use(swaggerConfig.routes()).use(swaggerConfig.allowedMethods());

// 使用景点路由
app.use(attractionRoute.routes()).use(attractionRoute.allowedMethods());
// 使用路线路由
app.use(routesRoute.routes()).use(routesRoute.allowedMethods());
// 使用门票路由
app.use(ticketsRoute.routes()).use(ticketsRoute.allowedMethods());
// 使用活动路由
app.use(activityRoute.routes()).use(activityRoute.allowedMethods());
// 使用酒店路由
app.use(accommodationRoute.routes()).use(accommodationRoute.allowedMethods());
// 使用 Swagger UI
app.use(
    koaSwagger({
        routePrefix: '/swagger', // host at /swagger instead of default /docs
        swaggerOptions: {
            url: '/swagger.json' // example path to json
        }
    })
);


app.listen(4000, () => {
    console.log('Server is running on port 4000');
});
